using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
           //让当前客户端复活角色
		    NetworkClient.AddPlayer();
        }
        
    }
    public static GameManager Instance { get; private set; }

    public Text roomListText;

    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
        }
    }

    public void UpdateRoomList(List<string> roomList)
    {
        // 清空房间列表文本
        roomListText.text = "";

        // 显示房间列表
        foreach (string roomName in roomList)
        {
            roomListText.text += roomName + "\n";
        }
    }

    // 创建房间按钮的点击事件
    public void OnCreateRoomButtonClicked()
    {
        NetworkManager.singleton.StartHost();
    }

    // 加入房间按钮的点击事件
    public void OnJoinRoomButtonClicked()
    {
        NetworkManager.singleton.StartClient();
    }
}
